package org.yhx.learning.verticle;/*
 * Copyright (C), 2024, bigmoon
 * FileName:
 * Author:   bigmoon
 * Date:     2024/9/4 16:20
 * Description: //模块目的、功能描述
 * History: //修改记录
 * &lt;author&gt;      &lt;time&gt;      &lt;version&gt;    &lt;desc&gt;
 * 修改人姓名             修改时间            版本号                  描述
 */

import io.vertx.core.AbstractVerticle;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 通过JSONOBject 或者JSONArray 床底配置数据，通过DeploymentOptions 给verticle实例
 */
public class OptinalVerticle extends AbstractVerticle {

    private static final Logger LOGGER = LoggerFactory.getLogger(OptinalVerticle.class);

    @Override
    public void start() throws Exception {
        LOGGER.info("n:{}",config().getInteger("n"));
    }

    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();
        JsonObject obj=new JsonObject();


        for (int i = 0; i < 5; i++) {
            obj.put("n",i*10);
            DeploymentOptions options=new DeploymentOptions().setConfig(obj).setInstances(1);
            vertx.deployVerticle(new OptinalVerticle(),options);
        }
    }
}
